import { defineStore } from 'pinia'

interface AppState {
  sys?: string | number
  config: IConfig
}

interface IConfig {
  user: UserConfig
  website: WebsiteConfig
  login: LoginConfig
  service: ServiceConfig
  share: ShareConfig
}
interface UserConfig {
  default_avatar?: string
}
interface WebsiteConfig {
  shop_logo?: string
  shop_name?: string
}

interface ServiceConfig {
  service_qrcode?: string
  service_phone?: string
}
interface LoginConfig {
  coerce_mobile?: number
}

interface ShareConfig {
  share_title?: string,
  mini_qrcode?: string,
  share_image?: string
}

export const useAppStore = defineStore({
  id: 'app-store',
  state: (): AppState => ({
    config: {
      user: {},
      website: {},
      login: {},
      service: {},
      share: {},
    }
  }),
  getters: {
    getUserConfig: state => state.config?.user,
    getWebsiteConfig: state => state.config?.website,
    getServiceConfig: state => state.config?.service,
    getShareConfig: state => state.config?.share
  },
  actions: {
    getConfig() {
      // const {data} = await getSysConfig()
      // this.config = data
    },
  },
})
